package com.it.xiaotao.steam;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class StreamDemo {
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("name", "张三");
        map.put("age", "李四");
        List collect = (List) map.keySet().stream()
                .map(r -> r.toString().substring(0, 2))
                .collect(Collectors.toList());
        System.out.println(collect.get(0));

        List collect1 = (List) map.keySet().stream().filter(r -> "name".equals(r)).collect(Collectors.toList());
        System.out.println(collect1.get(0));
    }
}
